<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>初始化 ReflectionClass 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.reflectionclass.html">« ReflectionClass</a></li>
      <li style="float: right;"><a href="reflectionclass.export.html">ReflectionClass::export »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionclass.html">ReflectionClass</a></li>
    <li>初始化 ReflectionClass 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionclass.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::__construct</span> &mdash; <span class="dc-title">初始化 ReflectionClass 类</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type">object</span>|<span class="type">string</span></span> <code class="parameter">$objectOrClass</code></span>)</div>

  <p class="para rdfs-comment">
    初始化新的 <span class="classname"><a href="class.reflectionclass.html" class="classname">ReflectionClass</a></span> 对象。
  </p>


 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">objectOrClass</code></dt>

     <dd>

      <p class="para">
       既可以是包含类名的字符串（<span class="type">string</span>）也可以是对象（<span class="type">object</span>）。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionclass.construct-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果要反射的 Class 不存在，抛出异常 <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5148">
    <p><strong>示例 #1 ReflectionClass 的基本用法</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />Reflection</span><span style="color: #007700">::</span><span style="color: #0000BB">export</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Exception'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Class [ &lt;internal:Core&gt; class Exception ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [7] {
    Property [ &lt;default&gt; protected $message ]
    Property [ &lt;default&gt; private $string ]
    Property [ &lt;default&gt; protected $code ]
    Property [ &lt;default&gt; protected $file ]
    Property [ &lt;default&gt; protected $line ]
    Property [ &lt;default&gt; private $trace ]
    Property [ &lt;default&gt; private $previous ]
  }

  - Methods [10] {
    Method [ &lt;internal:Core&gt; final private method __clone ] {
    }

    Method [ &lt;internal:Core, ctor&gt; public method __construct ] {

      - Parameters [3] {
        Parameter #0 [ &lt;optional&gt; $message ]
        Parameter #1 [ &lt;optional&gt; $code ]
        Parameter #2 [ &lt;optional&gt; $previous ]
      }
    }

    Method [ &lt;internal:Core&gt; final public method getMessage ] {
    }

    Method [ &lt;internal:Core&gt; final public method getCode ] {
    }

    Method [ &lt;internal:Core&gt; final public method getFile ] {
    }

    Method [ &lt;internal:Core&gt; final public method getLine ] {
    }

    Method [ &lt;internal:Core&gt; final public method getTrace ] {
    }

    Method [ &lt;internal:Core&gt; final public method getPrevious ] {
    }

    Method [ &lt;internal:Core&gt; final public method getTraceAsString ] {
    }

    Method [ &lt;internal:Core&gt; public method __toString ] {
    }
  }
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionobject.construct.html" class="methodname" rel="rdfs-seeAlso">ReflectionObject::__construct()</a> - Constructs a ReflectionObject</span></li>
    <li class="member"><a href="language.oop5.decon.html#language.oop5.decon.constructor" class="link">Constructors</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>